#!/bin/bash
echo "创建目录"
mkdir -p /home/srb/nacos/logs/               
mkdir -p /home/srb/nacos/init.d/
touch custom.properties
echo "server.contextPath=/nacos">>custom.properties
echo "server.servlet.contextPath=/nacos">>custom.properties
echo "server.port=8848">>custom.properties
echo "">>custom.properties
echo "spring.datasource.platform=mysql">>custom.properties
echo "db.num=1">>custom.properties
echo "db.url.0=jdbc:mysql://127.0.0.1:3306/nacos_dev?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true">>custom.properties
echo "db.user=root">>custom.properties
echo "db.password=123456">>custom.properties
echo "nacos.cmdb.dumpTaskInterval=3600">>custom.properties
echo "nacos.cmdb.eventTaskInterval=10">>custom.properties
echo "nacos.cmdb.labelTaskInterval=300">>custom.properties
echo "nacos.cmdb.loadDataAtStart=false">>custom.properties
echo "management.metrics.export.elastic.enabled=false">>custom.properties
echo "management.metrics.export.influx.enabled=false">>custom.properties
echo "server.tomcat.accesslog.enabled=true">>custom.properties
echo "server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D %{User-Agent}i">>custom.properties
echo "nacos.security.ignore.urls=/,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-fe/public/**,/v1/auth/login,/v1/console/health/**,/v1/cs/**,/v1/ns/**,/v1/cmdb/**,/actuator/**,/v1/console/server/**">>custom.properties
echo "nacos.naming.distro.taskDispatchThreadCount=1">>custom.properties
echo "nacos.naming.distro.taskDispatchPeriod=200">>custom.properties
echo "nacos.naming.distro.batchSyncKeyCount=1000">>custom.properties
echo "nacos.naming.distro.initDataRatio=0.9">>custom.properties
echo "nacos.naming.distro.syncRetryDelay=5000">>custom.properties
echo "nacos.naming.data.warmup=true">>custom.properties
echo "nacos.naming.expireInstance=true">>custom.properties

cp custom.properties /home/srb/nacos/init.d/

echo "安装nacos"
echo "拉取镜像--------------------------------------开始"
docker pull nacos/nacos-server
echo "拉取镜像--------------------------------------结束"
echo "启动nacos容器--------------------------------------开始"
docker  run \
--name nacos -d \
-p 8848:8848 \
--privileged=true \
--restart=always \
-e JVM_XMS=256m \
-e JVM_XMX=256m \
-e MODE=standalone \
-e PREFER_HOST_MODE=hostname \
-v /home/srb/nacos/logs:/home/nacos/logs \
-v /home/srb/nacos/init.d/custom.properties:/home/nacos/init.d/custom.properties \
nacos/nacos-server
echo "启动nacos容器--------------------------------------结束"